/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package upc.jfactory.scp.bl.controller;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import upc.jfactory.scp.jpa.bean.Postulante;
import upc.jfactory.scp.jpa.controlador.PostulanteJpaController;
import upc.jfactory.scp.jpa.controlador.exceptions.IllegalOrphanException;
import upc.jfactory.scp.jpa.controlador.exceptions.NonexistentEntityException;
import upc.jfactory.scp.jpa.controlador.exceptions.PreexistingEntityException;




/**
 *
 * @author Diego Tovar
 */
public class GestionarPerfilController
{
  public void Guardar(Postulante postulante){
        try {
            PostulanteJpaController postulanteJpaController = new PostulanteJpaController();
            postulanteJpaController.edit(postulante);
        } catch (NonexistentEntityException ex) {
            Logger.getLogger(GestionarPerfilController.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(GestionarPerfilController.class.getName()).log(Level.SEVERE, null, ex);
        }
    
  }
    public void Crear(Postulante postulante){
        try {
            PostulanteJpaController postulanteJpaController = new PostulanteJpaController();
            postulanteJpaController.create(postulante);
        } catch (PreexistingEntityException ex) {
            Logger.getLogger(GestionarPerfilController.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(GestionarPerfilController.class.getName()).log(Level.SEVERE, null, ex);
        }
   
  }

    public boolean BuscarPostulanteIgual(int id)
    {

        PostulanteJpaController postulanteJpaController = new PostulanteJpaController();
        List<Postulante> listaPostulante = new ArrayList<Postulante>();
        listaPostulante = postulanteJpaController.BuscarPostulantelExistentes(id);
        if(listaPostulante.isEmpty())
        {   return true;}
        else
        {
        return false;}
    }


   public List<Postulante> damepostulante(String codigo)
    {

        List<Postulante> listapostulante = new ArrayList<Postulante>();

        try{
                PostulanteJpaController postulanteJpaController= new PostulanteJpaController();
                listapostulante=postulanteJpaController.findPostulantexCodigo(codigo);

		}
        finally{
		return listapostulante;}

    }
   public Postulante damepostulantexid(int id){
            PostulanteJpaController postulanteJpaController= new PostulanteJpaController();
            return postulanteJpaController.findPostulante(id);
   }


}